//
//  StatusCellBottomView.m
//  王雷Sinoweibo
//
//  Created by wanglei on 16/11/23.
//  Copyright © 2016年 wanglei. All rights reserved.
//

#import "StatusCellBottomView.h"
#import "UIButton_Extesion.h"
#import "Masonry.h"
#define MAS_SHORTHAND
#define MAS_SHORTHAND_GLOBALS


@implementation StatusCellBottomView


//- (UINavigationController *)getNavigationController {
//    UIResponder *next = [self nextResponder];
//    while (next != nil) {
//        if ([next isKindOfClass:[UINavigationController class]]) {
//            return (UINavigationController *)next;
//        }
//        next = [next nextResponder];
//    }
//    return nil;
//}

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    self.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1];
    NSLog(@"%@",self);
    [self setupUi];
    return self;
}

- (void)repostBtnDidClick{
    TempViewController *tempviewController = [[TempViewController alloc]init];
//    UIView_ViewController *bottomView = [[UIView_ViewController alloc]init];
//    tempviewController.hidesBottomBarWhenPushed = true;
//    NSLog(@"%@",[bottomView getNavigationController]);
    [[self getNavigationController] pushViewController:tempviewController animated:NO];
}

- (void)setupUi{
    UIButton *repostBtn = [[UIButton_Extesion alloc]initWithTitle:@"转发" titleColor:[UIColor lightGrayColor] backImageName:nil imageName:@"timeline_icon_retweet" fontSize:14];
    UIButton *commentBtn = [[UIButton_Extesion alloc]initWithTitle:@"评论" titleColor:[UIColor lightGrayColor] backImageName:nil imageName:@"timeline_icon_comment" fontSize:14];
     UIButton *oYeahBtn = [[UIButton_Extesion alloc]initWithTitle:@"赞" titleColor:[UIColor lightGrayColor] backImageName:nil imageName:@"timeline_icon_unlike" fontSize:14];
    self.repostBtn = repostBtn;
    self.commentBtn = commentBtn;
    self.oYeahBtn = oYeahBtn;
  
//    切记,对于自定义的属性,一定要先实例化才能拿出来使用,这里view1表示分割线
    UIView *view1 = [[UIView alloc]init];
view1.backgroundColor = [UIColor darkGrayColor];

    UIView *view2 = [[UIView alloc]init];
    view2.backgroundColor = [UIColor darkGrayColor];
    [self addSubview:_repostBtn];
    [self addSubview:_commentBtn];
    [self addSubview:_oYeahBtn];
    [self addSubview:view1];
    [self addSubview:view2];
    
    [_repostBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.left.equalTo(self);
        make.right.equalTo(_commentBtn.mas_left);
    }];
    
    [_commentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.equalTo(self);
        make.left.equalTo(_repostBtn.mas_right);
        make.width.equalTo(_repostBtn.mas_width);
    }];
    
    [_oYeahBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.bottom.right.equalTo(self);
        make.left.equalTo(_commentBtn.mas_right);
        make.width.equalTo(_commentBtn);
    }];
  
    [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
        NSValue *sizeValue = [NSValue valueWithCGSize:CGSizeMake(0.5, 15)];
        make.centerY.equalTo(self.mas_centerY);
        make.left.equalTo(_repostBtn.mas_right);
        make.size.equalTo(sizeValue);
    }];
    [view2 mas_makeConstraints:^(MASConstraintMaker *make) {
        NSValue *sizeValue = [NSValue valueWithCGSize:CGSizeMake(0.5, 15)];
        make.centerY.equalTo(self.mas_centerY);
        make.left.equalTo(_commentBtn.mas_right);
        make.size.equalTo(sizeValue);
    }];
    
    [_repostBtn addTarget:self action:@selector(repostBtnDidClick) forControlEvents:UIControlEventTouchUpInside];
}
@end
